<template>
    <el-dialog title="办理" :close-on-click-modal="false" :visible.sync="visible">
        <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
            label-width="100px">

            <div>
                <p style="margin: 5px 0px 5px 32px;">申请用户：&ensp;{{this.dataForm.userName}}</p>
                <p style="margin: 5px 0px 5px 32px;">审核状态：&ensp;{{this.dataForm.verifyStatusStr}}</p>
                <p style="margin: 5px 0px 5px 32px;">采购类型：&ensp;{{this.dataForm.applyType}}</p>
                <p style="margin: 5px 0px 30px 32px;display: inline;">申请备注：&ensp;</p>
                <el-input style="width: 600px;" type="textarea" resize="none" maxlength="200" :disabled="true"
                    :autosize="{ minRows:1, maxRows: 6}" v-model="this.dataForm.note" />

            </div>

            <el-form-item style="margin-top: 30px;" label="办理意见" prop="verifyStatus">
                <el-select v-model="dataForm.verifyStatus" placeholder="请选择">
                    <el-option label="同意" value="3"></el-option>
                    <el-option label="不同意" value="2"></el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="批注" prop="verifyNote">
                <el-input type="textarea" maxlength="500" show-word-limit :autosize="{ minRows:4, maxRows: 6}"
                    v-model="dataForm.verifyNote"></el-input>
            </el-form-item>

        </el-form>

        <span slot="footer" class="dialog-footer">
            <el-button @click="visible = false">取消</el-button>
            <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
        </span>
    </el-dialog>
</template>

<script>
    export default {
        data() {
            return {
                visible: false,
                dataForm: {
                    id: 0,
                    verifyNote: '',
                    verifyStatus: undefined,
                    userName: undefined,
                    verifyStatusStr: undefined,
                    note: undefined,
                    beginTime: undefined,
                    fileName: undefined,
                    fileUrl: undefined
                },
                dataRule: {
                    verifyStatus: [
                        { required: true, message: '办理意见不能为空', trigger: 'blur' }
                    ],
                    verifyNote: [
                        { required: true, message: '批注不能为空', trigger: 'blur' }
                    ]
                }
            }
        },
        methods: {
            init(row) {
                this.dataForm.verifyStatus = ''
                this.dataForm.verifyNote = ''
                this.dataForm.id = row.id || 0
                this.value = ''
                this.visible = true

                // 申请用户 审核状态 申请备注  预计离职时间 附件
                this.dataForm.userName = row.resignationUserName
                this.dataForm.verifyStatusStr = row.verifyStatusStr
                this.dataForm.note = row.resignationNote
                this.dataForm.applyType = row.applyType
            },
            // 表单提交
            dataFormSubmit() {
                this.$refs['dataForm'].validate((valid) => {
                    if (valid) {
                        this.$http({
                            url: this.$http.adornUrl(`/examineapprove/receive-resignation/handle`),
                            method: 'post',
                            data: this.$http.adornData({
                                'id': this.dataForm.id || undefined,
                                'verifyStatus': this.dataForm.verifyStatus,
                                'verifyNote': this.dataForm.verifyNote
                            })
                        }).then(({ data }) => {
                            if (data && data.code === 0) {
                                this.$message({
                                    message: '操作成功',
                                    type: 'success',
                                    duration: 1500,
                                    onClose: () => {
                                        this.visible = false
                                        this.$emit('refreshDataList')
                                    }
                                })
                            } else {
                                this.$message.error(data.msg)
                            }
                        })
                    }
                })
            }
        }
    }
</script>

<style>
    a {
        cursor: pointer;
    }
</style>